﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DungeonCraft.DataModel.Abilities.Interfaces;

namespace DungeonCraft.DataModel.Abilities.Guards
{
    public class JumpingGuard : IGuard
    {
        public bool Check(DataModel.Interfaces.ILevel level, Player player, IAbility ability)
        {
            if (!player.canJump())
                return false;
            switch (player.Direction)
            {
                case Player.Directions.Up:
                    if (!level.LocationIsAllowed(player.Location.X, player.Location.Y - (2 * Block.height) - 1, player))
                        return false;
                    break;
                case Player.Directions.Down:
                    if (!level.LocationIsAllowed(player.Location.X, player.Location.Y + (2 * Block.height) + 1, player))
                        return false;
                    break;
                case Player.Directions.Left:
                    if (!level.LocationIsAllowed(player.Location.X - (2 * Block.width), player.Location.Y - 1, player))
                        return false;
                    break;
                case Player.Directions.Right:
                    if (!level.LocationIsAllowed(player.Location.X + (2 * Block.width), player.Location.Y + 1, player))
                        return false;
                    break;
            }
            return true;
        }
    }
}
